import requests from '@/utils/axios';

interface updateDatas {
  newDirId: number;
  portsIdList: number[];
}

interface selectDatas {
  portsName?: string;
  pageSize?: number;
  portsSource?: string;
  portsStatus?: number;
  pageNum: number;
}

interface pausetDatas {
  portsId: number[];
  portsStatus: number;
  dirId: number;
}

interface allInterDatas {
  dirName: string;
  dirId: number;
  dirParents: number;
  dirLevel: number;
}
interface Registration {
  portsName: string;
  dirId: number;
  portsSource: string;
  portsMsg: string | null;
  portsProtocol: number;
  portsIp: string;
  portsPath: string;
  portsRequestMethod: number;
  portsOutTime: number;
}

interface Registration2 {
  paramsName: string;
  paramsPath: number;
  paramsType: number;
  paramsIsNull: number;
  paramsDefault: string;
  paramsMsg: string;
  paramsParents: number;
  codesId: string;
}

interface Registrationbody {
  portsName?: string;
  dirId?: number;
  bodyName: string;
  bodyType: number;
  bodyIsNull: number;
  bodyDefault: string;
  bodyMsg: string;
  bodyParents: number;
  requestBodyListVoList: {
    bodyName: string;
    bodyType: number;
    bodyIsNull: string;
    bodyDefault: string;
    bodyMsg: string;
    bodyParents: string;
    codesId: string;
  };
}

interface ApifoxModal {
  dirName?: string;
  dirParents?: number;
}

interface updateDir {
  dirName: string;
  dirId: number;
}

interface deleteDir {
  dirId: number;
}

interface RequestParam {
  portsId: number;
  portsName: string;
  dirId: number;
  portsSource: string;
  portsMsg: string;
  portsProtocol: number;
  portsIp: string;
  portsPath: string;
  portsRequestMethod: number;
  portsOutTime: number;
}

interface returnParam {
  returnName: string | null;
  returnType: number;
  returnParents: number;
  codesId: string | null;
  returnMsg: string | null;
  portsId: number | null;
}

interface selectDir {
  dirId: number;
  pageNum?: number;
  pageSize?: number;
}

//删除  /interfaceManage/deleteInterface
export const delData = (params: { portsId: number }) => requests({ url: '/interfaceManage/deleteInterface', method: 'delete', params });

//批量分类 /interfaceManage/editBatchClassify
export const editBatchClassify = (data: updateDatas) => requests({ url: '/interfaceManage/editBatchClassify', method: 'put', data });

//批量停用和批量发布 /interfaceManage/editBatchPublishOrStop
export const pauseAndIssueAllStatus = (data: pausetDatas) => requests({ url: '/interfaceManage/editBatchPublishOrStop', method: 'put', data });

//条件查询 /interfaceManage/getAllInterfactByTerm post
export const getData = (data: selectDatas | Object) => requests({ url: '/interfaceManage/getAllInterfactByTerm', method: 'post', data });

//查询所有接口分类 /interfaceManage/getDirectory get
export const getinterFace = () => requests({ url: '/interfaceManage/getDirectory', method: 'get' });

//下拉框接口  /interfaceManage/getSource get
export const interFace = () => requests({ url: '/interfaceManage/getSource', method: 'get' });

//查询接口api请求路径  /interfaceManage/queryApiInfo/{interfaceId} get
export const queryApiInfo = (data: { interfaceId: number }) => requests({ url: `/interfaceManage/queryApiInfo/${data.interfaceId}`, method: 'get' });

//查询接口请求体以及响应参数的详细信息  /interfaceManage/queryParamsInfo/{interfaceId}  get
export const queryParamsInfo = (data: { interfaceId: number }) => requests({ url: `/interfaceManage/queryParamsInfo/${data.interfaceId}`, method: 'get' });

//人工注册第一步  /interfaceManage/manualRegistration post
export const Registration1 = (data: Registration) => requests({ url: '/interfaceManage/manualRegistration', method: 'post', data });

//人工注册第2步输入参数  /interfaceManage/insertInputParams post
export const RegistrationInput = (data: Registration2) => requests({ url: '/interfaceManage/insertInputParams', method: 'post', data });

//人工注册第2步请求body  /interfaceManage/RequestBody  post
export const RegistrationBody = (data: Registrationbody) => requests({ url: '/interfaceManage/RequestBody', method: 'post', data });

//人工注册第2步返回参数  /interfaceManage/returnParam  post
export const RegistrationBack = (data: Registrationbody) => requests({ url: '/interfaceManage/returnParam', method: 'post', data });

//新增目录 /interfaceManage/addDir post
export const addDir = (data: ApifoxModal) => requests({ url: '/interfaceManage/addDir', method: 'post', data });

//修改目录名称  /interfaceManage/updateDirName put
export const updateDir = (data: updateDir) => requests({ url: '/interfaceManage/updateDirName', method: 'put', data });

//删除目录  /interfaceManage/deleteDir delete
export const deleteDir = (params: { dirId: number }) => requests({ url: '/interfaceManage/deleteDir', method: 'delete', params });

//第一步编辑 修改接口基本信息  /interfaceManage/editApiRequestParam  put
export const editApiRequestParam = (data: RequestParam) => requests({ url: '/interfaceManage/editApiRequestParam', method: 'put', data });

//人工注册第二步返回参数  /interfaceManage/returnParam  get
export const returnParam = (data: returnParam) => requests({ url: '/interfaceManage/returnParam', method: 'get', data });

//修改接口参数详细信息  /interfaceManage/editParams put
// export const editParams = (data: editParams) => requests({ url: '/interfaceManage/editParams', method: 'put', data });

//查询目录下的接口  /interfaceManage/getInterfaceByDir post
export const selectDirData = (data: selectDir) => requests({ url: '/interfaceManage/getInterfaceByDir', method: 'post', data });
//单个接口查询 /interfaceManage/getOnePort  get
export const selectDir = (params: { portsId: number }) => requests({ url: '/interfaceManage/getOnePort', method: 'get', params });
//接口测试
export const testInterface = (data: any) => requests({ url: '/interfaceManage/Testinterface', method: 'post', data });
